<template>
  <div class="aside-nav">
    <el-menu
      :default-active="activeIndex"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      @select="handleSelect"
      :collapse="isCollapse"
    >
      <el-menu-item index="collapse">
        <i :class="isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'"></i>
        <span slot="title"
          ><b>{{ isCollapse ? "展开" : "收起" }}</b></span
        >
      </el-menu-item>
      <!-- <el-menu-item
        index="Home"
        @click="$router.replace('./home').catch((err) => {})"
      >
        <i class="el-icon-s-home"></i>
        <span slot="title">主页</span>
      </el-menu-item> -->
      <el-menu-item
        index="Market"
        @click="$router.replace('./market').catch((err) => {})"
      >
        <i class="el-icon-s-marketing"></i>
        <span slot="title">交易</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
export default {
  name: "AsideNav",
  model: {
    prop: "activeIndex",
    event: "select",
  },
  props: {
    activeIndex: String,
  },
  data() {
    return {
      isCollapse: true,
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
      if (key === "collapse") {
        this.isCollapse = !this.isCollapse;
        return;
      }
      this.$emit("select", key);
    },
  },
};
</script>

<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.aside-nav > .el-menu-vertical-demo {
  border: none;
}
.aside-nav {
  height: 100%;
  border-right: 1px solid #e4e7ed;
}
</style>
